﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PagedList;
using PagedList.Mvc;

namespace shop.Areas.admin.Controllers
{
    public class PartialController : Controller
    {
        //
        // GET: /admin/Partial/
        private LongHAEntities db = new LongHAEntities();
        public ActionResult Index()
        {
            return View();
        }
        public PartialViewResult selectDM(string type, int? IDCon)
        {
            ViewBag.type = type;
            ViewBag.IDCon = IDCon;
            var data = db.DanhMucs.Where(s => s.Cha == true).ToList();
            return PartialView(data);
        }
        // dropmenu
        public PartialViewResult DropMenuChaDM(string type,   string MaDM)
        {
            
              ViewBag.MaDM   = MaDM ;
               var data = db.DanhMucs.Where(s=>s.Cha==true).ToList();
               ViewBag.type = type;
               return PartialView(data);
        }
        public PartialViewResult DropMenuChaTH(string type, string MaTH)
        {

            var data = db.ThuongHieux.Where(s => s.Cha == true).ToList();
            ViewBag.MaTH= MaTH;
            ViewBag.type = type;
            return PartialView(data);
        }
        public PartialViewResult DropMenuConDM(string type, int IDcha, string ty, string MaDM)
        {
                ViewBag.ty = ty;
               ViewBag.MaDM = MaDM;
                var data = db.DanhMucs.Where(s => s.IDCon == IDcha).ToList();
                return PartialView(data);
        }
        public PartialViewResult DropMenuConTH(string type, int IDcha, string ty , string MaTH)
        {
            ViewBag.ty = ty;
            ViewBag.MaTH = MaTH;
            var data = db.ThuongHieux.Where(s => s.IdCon == IDcha).ToList();
            return PartialView(data);
        }

        public PartialViewResult DropMenuNN(string type , string MaNN)
        {
            var data = db.NgheNghieps.ToList();
            ViewBag.type = type;
            ViewBag.MaNN = MaNN;
            return PartialView(data);
        }
        public PartialViewResult ListProduct(int pagesize , int ? page=1)
        {
            var data = db.SanPhams.ToList();
            int pagenumber = (page ?? 1);
            return PartialView(data.ToPagedList(pagenumber,pagesize));
        }

        // lấy ra bảng màu 
       public PartialViewResult BangMau()
        {
            var data = db.Maus.ToList();
            return PartialView(data);
        }  
        public PartialViewResult Size()
       {
           var data = db.KichThuocs.ToList() ;
           return PartialView(data);
       }
        //
        // GET: /admin/Partial/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /admin/Partial/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /admin/Partial/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /admin/Partial/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /admin/Partial/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /admin/Partial/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /admin/Partial/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
